package com.leijie.protobuf.server;

import com.leijie.protobuf.DataInfo;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author LeiJie
 * @time 2020-4-28 17:42
 * @desc TODO
 */
public class AppServerHandle extends SimpleChannelInboundHandler<DataInfo.Body> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DataInfo.Body msg) {
        System.out.println(ctx.channel()+"client input >>>");
        switch (msg.getDataType()){
            case CAT:
                DataInfo.Cat cat = msg.getCat();
                System.out.println("名称："+cat.getName());
                System.out.println("爱好："+cat.getHobby());
                break;
            case DOG:
                DataInfo.Dog dog = msg.getDog();
                System.out.println("名称："+dog.getName());
                System.out.println("颜色："+dog.getColor());
                break;
            case PEOPLE:
                DataInfo.People people = msg.getPeople();
                System.out.println("名称："+people.getName());
                System.out.println("年龄："+people.getAge());
                System.out.println("地址："+people.getAddresss());
                break;
            default:
        }
        System.out.println("---------------------------------");
    }
}
